home *** CD-ROM | disk | FTP | other *** search
- unit Mr_form;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, Grids, DBGrids, DB, DBTables;
-
- type
- TForm1 = class(TForm)
- DataSource1: TDataSource;
- Table1: TTable;
- DBGrid1: TDBGrid;
- Table1CustNo: TFloatField;
- Table1Company: TStringField;
- Table1Addr1: TStringField;
- Table1Addr2: TStringField;
- Table1City: TStringField;
- Table1State: TStringField;
- Table1Zip: TStringField;
- Table1Country: TStringField;
- Table1Phone: TStringField;
- Table1FAX: TStringField;
- Table1TaxRate: TFloatField;
- Table1Contact: TStringField;
- Table1LastInvoiceDate: TDateTimeField;
- procedure DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
- Field: TField; State: TGridDrawState);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect;
- Field: TField; State: TGridDrawState);
- var
- TextBox: TRect;
- begin
- if Field = Table1CustNo then { Draw contents of first column }
- begin
- with DBGrid1.Canvas do
- begin
-
- Font.Color := clBlack ;
- Font.Name := 'MS Sans Serif' ;
- Font.Size := 8 ;
- Font.Style := [];
-
- if gdSelected in State then
- begin
- Font.Color := clHighlightText ;
- Brush.Color := clHighlight;
- end ;
-
- TextBox.Left := Rect.Left + 1;
- TextBox.Top := Rect.Top + 1;
- TextBox.Right := Rect.Right - 1;
- TextBox.Bottom := Rect.Top + Abs( Font.Height ) + 3;
-
- TextRect( TextBox, TextBox.Left, TextBox.Top, 'Customer: ' );
-
- Font.Style := [ fsBold ] ;
-
- TextBox.Top := TextBox.Bottom + 1 ;
- TextBox.Bottom := TextBox.Top + Abs( Font.Height) + 3;
-
- TextRect( TextBox, TextBox.Left, TextBox.Top, Table1Company.AsString );
-
- Font.Style := [ ] ;
-
- TextBox.Top := TextBox.Bottom + 1 ;
- TextBox.Bottom := TextBox.Top + Abs( Font.Height) + 3;
-
- TextRect( TextBox, TextBox.Left, TextBox.Top, 'Contact: ' );
-
- Font.Style := [ fsBold ] ;
-
- TextBox.Top := TextBox.Bottom + 1 ;
- TextBox.Bottom := TextBox.Top + Abs( Font.Height) + 3;
-
- TextRect( TextBox, TextBox.Left, TextBox.Top, Table1Contact.AsString );
-
- Font.Style := [ ] ;
-
- TextBox.Top := TextBox.Bottom + 1 ;
- TextBox.Bottom := TextBox.Top + Abs( Font.Height) + 3;
-
- TextRect( TextBox, TextBox.Left, TextBox.Top, 'Phone: ' );
-
- Font.Style := [ fsBold ] ;
-
- TextBox.Top := TextBox.Bottom + 1 ;
- TextBox.Bottom := TextBox.Top + Abs( Font.Height) + 3;
-
- TextRect( TextBox, TextBox.Left, TextBox.Top, Table1Phone.AsString );
-
- end ;
- end
- else if Field = Table1Company then { Draw contents of second column }
- begin
- with DBGrid1.Canvas do
- begin
-
- Font.Color := clBlack ;
- Font.Name := 'MS Sans Serif' ;
- Font.Size := 8 ;
- Font.Style := [];
-
- if gdSelected in State then
- begin
- Font.Color := clHighlightText ;
- Brush.Color := clHighlight;
- end ;
-
- TextBox.Left := Rect.Left + 1;
- TextBox.Top := Rect.Top + 1;
- TextBox.Right := Rect.Right - 1;
- TextBox.Bottom := Rect.Top + Abs( Font.Height ) + 3;
-
- TextRect( TextBox, TextBox.Left, TextBox.Top, 'Address: ' );
-
- Font.Style := [ fsBold ] ;
-
- TextBox.Top := TextBox.Bottom + 1 ;
- TextBox.Bottom := TextBox.Top + Abs( Font.Height) + 3;
-
- TextRect( TextBox, TextBox.Left, TextBox.Top, Table1Addr1.AsString );
-
-
- TextBox.Top := TextBox.Bottom + 1 ;
- TextBox.Bottom := TextBox.Top + Abs( Font.Height) + 3;
-
- TextRect( TextBox, TextBox.Left, TextBox.Top, Table1Addr2.AsString );
-
- TextBox.Top := TextBox.Bottom + 1 ;
- TextBox.Bottom := TextBox.Top + Abs( Font.Height) + 3;
-
- TextRect( TextBox, TextBox.Left, TextBox.Top, Table1City.AsString );
- TextBox.Top := TextBox.Bottom + 1 ;
- TextBox.Bottom := TextBox.Top + Abs( Font.Height) + 3;
-
- TextRect( TextBox, TextBox.Left, TextBox.Top,
- Table1State.AsString + ' ' + Table1Zip.AsString
- );
-
- TextBox.Top := TextBox.Bottom + 1 ;
- TextBox.Bottom := TextBox.Top + Abs( Font.Height) + 3;
-
- TextRect( TextBox, TextBox.Left, TextBox.Top, Table1Country.AsString );
- end;
- end;
- end;
-
- end.
-